<!doctype html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">

    <link rel="stylesheet" href="css/login.css">
   <script src="js/jquery-3.4.1.js" type="text/javascript" charset="utf-8"></script>
	<script src="lib/layui/layui.all.js" type="text/javascript" charset="utf-8"></script>
	<title>电厂信息业务支撑平台</title>
	<script type="text/javascript">
		$(function(){
		   $("#sub_btn").on("click",function(){
			    var username=$("#usernamebtn").val();
				var userpwd=$("#userpwd").val();
				var flag=0;
				if(username==""||username.length==0){
					layer.tips("用户名不得为空呀!", "#usernamebtn", {time: 3000});
				}
				else if(userpwd.length==0){
				   layer.tips("密码不能为空呀!", "#userpwd", {time: 3000});
				}
				else if(userpwd.length<3){
				   layer.tips("密码有点短呀!", "#userpwd", {time: 3000});
				   }
				else{
					$.ajax({
						type:"get",
						dataType:"json",
						url:"json/userinfo.json",
						success:function(user){
							console.log(username);
							console.log(userpwd);
						 for(var i=0;i<user.length;i++){
						   if(username==user[i].name&&userpwd==user[i].password){
							    window.location.href="index.html"
								break;
						   }
						   else{flag++;continue;}
						 }	
						 if(flag==user.length){
							 alert("用户名密码不正确！请重试");
						 }	
							
						},
					});
				}
		   });
		})
	</script>
	
</head>
<body>
	<div id="login_top">
		<div id="welcome">
			欢迎使用电厂信息业务支撑平台
		</div>
		<div id="back">
			<a href="#">返回</a>&nbsp;&nbsp; | &nbsp;&nbsp;
			<a href="#">帮助</a>
		</div>
	</div>
	<div id="login_center">
		<div id="login_area">
			<div id="login_form">
				<form  method="post">
					<div id="login_tip">
						用户登录   UserLogin
					</div>
					<div><input type="text" class="username" id="usernamebtn"></div>
					<div><input type="password" class="pwd" id="userpwd"></div>
					<div id="btn_area">
						<input type="button" name="submit" id="sub_btn" value="登录"></a>
						<input type="text" class="verify">
						<img src="images/login/verify.png" alt="" width="80" height="40">
					</div>
				</form>
			</div>
		</div>
	</div>
	<div id="login_bottom">
		版权所有
	</div>
</body>
</html>
